# 字典类型
from datetime import datetime

from flask_restful import abort
from sqlalchemy.orm import validates

from apps.model.baseModel import BaseModel
from apps.settingApi.api.funs.model import funsModel
from comm.sqlalchemyConfig import db

class lesseesModel(db.Model):
    """
    租户表
    """
    __tablename__ = 'tx_lessees'
    id = db.Column(db.String(100), primary_key=True, autoincrement=False,doc='id')
    name = db.Column(db.String(125), nullable=False,unique=True,doc='租户名称')
    type = db.Column(db.Integer, nullable=False, default=2, doc='租户类型', comment="1、经销商；2、普通租户")
    online_num = db.Column(db.Integer, nullable=True, default=10, doc='用户数')
    start_time = db.Column(db.DateTime, default=datetime.now, nullable=True,doc='启用日期')
    end_time = db.Column(db.DateTime, default=datetime.now, nullable=True,doc='停用日期')
    create_user = db.Column(db.String(50), nullable=True)
    create_time = db.Column(db.DateTime, default=datetime.now, nullable=True)
    update_user = db.Column(db.String(50), nullable=True)
    update_time = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now, nullable=True)
    rem = db.Column(db.Text, nullable=True, default='', doc='备注')

class lesseesFunsModel(BaseModel):
    """
    租户具有的菜单（功能模块）
    """
    __tablename__ = 'tx_lessees_funs'
    id = db.Column(db.String(100), primary_key=True, autoincrement=False,doc='id')
    funs_code = db.Column(db.String(100), db.ForeignKey('tx_funs.code'),doc='归属模块code')


